package com.example.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;



@Controller
public class MyController {

    @GetMapping("/login")
    public String login(){
        return "login";
    }

    @RequestMapping("/Tologin")
    public String login(HttpServletRequest req, Model model){
        String username = req.getParameter("name");
        String password = req.getParameter("password");
        System.out.println(username);
        System.out.println(password);
        if(username.equals("yangxinyi") && password.equals("2021443268"))
        {
            System.out.println("登录成功！");
            username=username.toUpperCase();
            //传到前端页面
            model.addAttribute("msg",username);
            return "success";
        }
        else
        {
            System.out.println("登录失败！");
            model.addAttribute("errorInfo","username or password is ERROR");
            return "login";
        }
    }

}
